package com.swsc.ai;

import constant.CommonConstant;
import tasks.LoadFile;

import java.io.IOException;
import java.util.HashMap;

/**
 * @describe: 启动类
 * @author: 容若
 * @created: 2024-08-07 11:01
 */
public class MainTaskStarter {
    // 入参格式：-filePath C:/data/test.txt 或 C:\\data\\test.txt
    public static void main(String[] args){
        HashMap<String, String> paramMap = new HashMap<>();
        if (args.length == 0){
            throw new RuntimeException("缺少必要参数");
        }
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (arg.startsWith("-")) {
                String key = arg.substring(1);
                String value = args[++i];
                paramMap.put(key, value);
            }
        }
        LoadFile loadFile = new LoadFile();
        try {
            String res = loadFile.loadFile(paramMap.get(CommonConstant.FILE_PATH_PARAM));
            System.out.println("****************" + res + "****************");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
